package com.zzyl.config;

import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIotConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliIotConfig {
    @Autowired
    private AliIotConfigProperties aliIotConfigProperties;

    @Bean
    public Client instance() throws Exception {
        Config config = new Config();
        config.accessKeyId = aliIotConfigProperties.getAccessKeyId();
        config.accessKeySecret = aliIotConfigProperties.getAccessKeySecret();
        // 您的可用区ID 默认上海
        config.regionId  = aliIotConfigProperties.getRegionId();
        return new Client(config);
    }
}
